package org.example.rtc.controller;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.example.rtc.model.entity.PatDrug;
import org.example.rtc.model.entity.PatInfo;
import org.example.rtc.model.entity.PatVitalInfo;
import org.example.rtc.model.entity.dto.R;
import org.example.rtc.service.PatDrugService;
import org.example.rtc.service.PatInfoService;
import org.example.rtc.service.PatVitalInfoService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/pat")
@RequiredArgsConstructor
@Slf4j
public class PatApi {

    private final PatInfoService patInfoService;
    private final PatDrugService patDrugService;
    private final PatVitalInfoService patVitalInfoService;

    @GetMapping("/getAllPat")
    public R<List<PatInfo>> getAllPat(){
        R<List<PatInfo>> success = R.success(patInfoService.list());
        log.info("getAllPat success:{}", success);
        return success;
    }

    @GetMapping("/getAllPat/{id}")
    public R<PatInfo> getById(@PathVariable("id") Long id){
        return R.success(patInfoService.getById(id));
    }

    @GetMapping("/getDrugs/{patId}")
    public R<List<PatDrug>> getDrugs(@PathVariable("patId") String patId){
        return R.success(patDrugService.getByPatId(patId));
    }

    @GetMapping("/getVitalInfo/{patId}")
    public R<List<PatVitalInfo>> getVitalInfo(@PathVariable("patId") String patId){
        return R.success(patVitalInfoService.getByPatId(patId));
    }


}
